/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.woupla.model;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Dimitri Lebel
 */
@Entity
@Table(name = "produit_generique")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "ProduitGenerique.findAll", query = "SELECT p FROM ProduitGenerique p"),
    @NamedQuery(name = "ProduitGenerique.findById", query = "SELECT p FROM ProduitGenerique p WHERE p.id = :id"),
    @NamedQuery(name = "ProduitGenerique.findByLabel", query = "SELECT p FROM ProduitGenerique p WHERE p.label = :label")})
public class ProduitGenerique implements Serializable {

    /**
	 * 
	 */
	private static final long serialVersionUID = 7213510202778898525L;
	@Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Integer id;
    @Basic(optional = false)
    @Column(name = "label")
    private String label;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "produitGenerique")
    private Collection<Companyproduit> companyproduitCollection;
    @JoinColumn(name = "category", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private Category category;

    public ProduitGenerique() {
    }

    public ProduitGenerique(Integer id) {
        this.id = id;
    }

    public ProduitGenerique(Integer id, String label) {
        this.id = id;
        this.label = label;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getLabel() {
        return label;
    }

    public void setLabel(String label) {
        this.label = label;
    }

    @XmlTransient
    public Collection<Companyproduit> getCompanyproduitCollection() {
        return companyproduitCollection;
    }

    public void setCompanyproduitCollection(Collection<Companyproduit> companyproduitCollection) {
        this.companyproduitCollection = companyproduitCollection;
    }

    public Category getCategory() {
        return category;
    }

    public void setCategory(Category category) {
        this.category = category;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof ProduitGenerique)) {
            return false;
        }
        ProduitGenerique other = (ProduitGenerique) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "javaapplication1.ProduitGenerique[ id=" + id + " ]";
    }
    
}
